#include <arch.h>
#include "multiboot.h"
#include "archinc.h"
#include "dt.h"
#include <types.h>

int mem = 0;
extern int main();
extern void syscallisr();
multiboot_info_t *multiboot;

void 
__start(multiboot_info_t *mb)
{
	mem = mb->mem_lower + mb->mem_upper;
	arch_info.mem_size = mem;
	multiboot = mb;
	if(mb->vbe_control_info != 0)
	{
		arch_info.video_mode = VIDEO_MODE_GRAPH;
	}
	else
	{
		arch_info.video_mode = VIDEO_MODE_TEXT;
	}
	
	asm("cli");

	gdt_install();
	idt_install();
	isrs_install();
	irq_install();	
	timer_init();
	clock_init();

    //idt_set_gate(SYSCALL_INT, (uint32_t) syscallisr, 0x08, 0x8E);
	asm("sti");
	
	main();
}


uint64_t 
arch_mem_total()
{	
	return mem;
}

uint8_t 
arch_init()
{
	return 0;
}


void 
arch_shutdown()
{

}



void 
arch_reboot()
{


}


void 
arch_standby()
{

}


uint32_t 
cpu_num()
{
	return 1;
	
}

uint32_t 
cpu_whake(uint32_t n)
{
	return 1;
}



